package com.TP.www.service;

import com.TP.www.dao.impl.CustomerDAO;
import com.TP.www.dao.impl.MerchantDAO;
import com.TP.www.po.Customer;
import com.TP.www.po.Merchant;

import java.util.List;



/**
 * @author 邱彦祥
 * 注册接口
 */
public interface Register {
    /**
     * 注册方法
     */
     void register();

    /**
     * 查询注册用户名是否存在与当前已注册用户重名现象
     * @param name 注册名
     * @return 真则不允许注册 假则允许注册
     */
    static boolean check(String name){
        String customerSql = "select * from customer where name = ? ;";
        String merchantSql = "select * from merchant where name = ? ;";
        List<Customer> customer = new CustomerDAO().executeQuery(customerSql,name);
        List<Merchant> merchant = new MerchantDAO().executeQuery(merchantSql,name);
        return !customer.isEmpty() || !merchant.isEmpty();
    }
}
